/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.itsc.ds2.bl;

import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import mx.itsc.ds2.dao.MusicalGenresDaoLocal;
import mx.itsc.ds2.enumerations.TransactionStatus;
import mx.itsc.ds2.model.MusicalGenres;

/**
 *
 * @author Eli
 */
@Stateless
public class MusicalGenre implements MusicalGenreLocal {
    @EJB
    private MusicalGenresDaoLocal musicalGenresDao;

    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")

    @Override
    public TransactionStatus register(MusicalGenres musicalGenre) {
              if (musicalGenresDao.findByName(musicalGenre)) {
            return TransactionStatus.INCOMPLETE;
        } else {
            musicalGenresDao.create(musicalGenre);
            return TransactionStatus.COMPLETE;
        }
    }

    @Override
    public TransactionStatus modify(MusicalGenres musicalGenre) {
         if (musicalGenre.getIdgenre() == null || musicalGenresDao.find(musicalGenre.getIdgenre()) == null) {
            return TransactionStatus.INCOMPLETE;
        } else {
            musicalGenresDao.edit(musicalGenre);
            return TransactionStatus.COMPLETE;
        }
    }

    @Override
    public TransactionStatus delete(MusicalGenres musicalGenre) {
            if (musicalGenre.getIdgenre() == null || musicalGenresDao.find(musicalGenre.getIdgenre()) == null) {
            return TransactionStatus.INCOMPLETE;
        } else {
            musicalGenresDao.remove(musicalGenre);
            return TransactionStatus.COMPLETE;
        }
    }

    @Override
    public List<MusicalGenres> getAll() {
        return musicalGenresDao.findAll();
    }

    
    
}
